Error Message Customization

Use RegisterJScriptAlert to Display Messages

Description
The RegisterJScriptAlert method can be used to display a message in user defined methods, BaseClasses methods, or in events.
Variables
Button Control
Select the button
Applies to
P_Button Control class
Code
 
''' 
''' Event handler for Button. Add custom logic to display an error message on ${Button Control}_Click
''' 
Public Overrides Sub ${Button Control}_Click(ByVal sender As Object, ByVal args As EventArgs)

    ' Add your logic to decide when to display alert message
	BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "MyAlertName", "My Alert Text")
    
	' If you are redirecting to some other page then, it should not redirect when you display the alert message. Otherwise, the alert message will not be displayed.
	' For this, you can use the following logic:
	   
	'	Dim shouldRedirect As Boolean = True
	'	If "Show alert message codition is true" Then
	'	  BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "MyAlertName", "My Alert Text")
	'	  shouldRedirect = False
	'   End If
	'	If shouldRedirect Then
    '           Me.Page.ShouldSaveControlsToSession = True
    '           Me.Page.Response.Redirect(url)
	'	End If
End Sub
 

Terms of Service Privacy Statement